<template>
    <div class="musicDetail">
        <!-- 头部详情 -->
        <div class="top">
            <img class="topbg" :src="Detail.coverImgUrl" alt="">
            <div class="shadow"></div>
            <div class="detail">
                <p class="title">{{Detail.name}}</p>
                <p class="author">
                    <img :src="Detail.creator.avatarUrl" alt="">
                    {{Detail.creator.nickname}}
                </p>
                <p>{{Detail.description.slice(0,18)}}...</p>
            </div>
            
            <div class="Count">
                <p>收藏:{{Detail.subscribedCount}}</p>|
                <p>评论:{{Detail.commentCount}}</p>|
                <p>分享:{{Detail.shareCount}}</p>
            </div>
        </div>

        <!-- 歌单列表 -->
        <div class="content">
            <div class="item" v-for="(item,index) of Detail.tracks" :key="item.id">
                <span>{{index+1}}</span>
                <img :src="item.al.picUrl" alt="">
                <div class="song">
                    <p class="s-title">{{item.name}}</p>
                    <p class="s-name">{{item.ar[0].name}}</p>
                </div>
                <div class="time">{{item.time}}</div>
                <div>
                    <img src="../../../assets/images/icon/pause.png" @click="goSong(item.id)" alt="">
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            Detail:{},
        }
    },
    mounted() {
        var {id} = this.$route.params;
        console.log(id);
        this.$http(`http://122.112.161.135:3000/playlist/detail?id=${id}`).then(res=>{
            this.Detail = res.data.playlist;
            this.Detail.tracks.forEach(item=>{
                var seconds = Math.floor((item.dt/1000)%60)
                if(seconds<10){
                    seconds = "0"+seconds
                }
                item.time = "0"+String(Math.floor((item.dt/1000)/60))+":"+String(seconds)
            })
        })
    },
    methods: {
        goSong(id){
            this.$router.push(`/music/song/${id}`)
        }
    },
}
</script>

<style scoped>
.top{
    width: 100%;
    height: 5rem;
    background-color: #584446;
    display: flex;
    justify-content: space-between;
    position: relative;
}
.topbg{
    width: 3rem;
    height: 3rem;
    border-radius: 0.3rem;
    margin: 1rem 0 0 0.5rem;
    position: relative;
    z-index: 100;
}
.shadow{
    position: absolute;
    width: 2.5rem;
    height: 3rem;
    top: 0.8rem;left:0.75rem;
    background-color: #695557;
    z-index: 10;
    border-radius: 0.3rem;
}
.detail{
    margin-top: 1rem;
    margin-right: 0.2rem;
    width: 6rem;
    color: #cac9c9;
    font-size: 0.4rem;
}
.detail .title{
    font-size: 0.5rem;
    color: #fff;
}
.author{
    display: flex;
    align-items: center;
    margin: 0.15rem 0;
}
.author img{
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    margin-right: 0.2rem;
}
.Count{
    position: absolute;
    bottom: -0.7rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 1.4rem;
    border-radius: 0.7rem;
    border: 1px solid #ccc;
    width: 7rem;
    font-size: 0.35rem;
}
.Count p{
    margin: 0 0.3rem;
}
.content{
    padding: 1.2rem 0.3rem;
}
.item {
    display: flex;
    align-items: center;
}
.item>img{
    width: 2rem;
    height: 2rem;
    margin: 0.4rem 0.2rem;
}
.item span{
    color: #888;
    font-size: 0.5rem;
    width: 0.7rem;
}
.song{
    font-size: 0.4rem;
}
.s-title{
    width: 3.5rem;
    margin-bottom: 0.2rem;
}
.s-name{
    color: #888;
}
.time{
    margin: 0 0.3rem;
}
</style>